<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--样式-->
    <style>
        table{
            width:200px;
        }
    </style>
</head>
<body>
    <!--结构-->
    <table border=1;>
        <tr><td>1</td><td>2</td><td>3</td></tr>
        <tr><td>1</td><td>2</td><td>3</td></tr>
        <tr><td>1</td><td>2</td><td>3</td></tr>
    </table>
    <!--行为-->
    <script>
        var myTrs = document.getElementsByTagName('td');
        var len = myTrs.length;
        for (i=0;i<len;i++){
            myTrs[i].onmouseover = function () {
                this.style.backgroundColor = 'red';
            };
            myTrs[i].onmouseout = function () {
                this.style.backgroundColor = '';
            };
        }
    </script>
</body>
</html>